<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>fdetach</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_004_173">&nbsp;</a>NAME</h4><blockquote>
fdetach - detach a name from a STREAMS-based file descriptor
</blockquote><h4><a name = "tag_000_004_174">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="stropts.h.html">stropts.h</a>&gt;

int fdetach(const char *<i>path</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_004_175">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>fdetach()</i>
function detaches a STREAMS-based file from
the file to which it was attached by a previous call to
<i><a href="fattach.html">fattach()</a></i>.
The <i>path</i> argument points to the pathname of the attached STREAMS file.
The process must have appropriate privileges or be the owner of the file.
A successful call to
<i>fdetach()</i>
causes all pathnames that named the attached STREAMS file to again name the
file to which the STREAMS file was attached.  All subsequent operations on
<i>path</i> will operate on the underlying file and not on the STREAMS file.
<p>
All open file descriptions established while the STREAMS file was attached to
the file referenced by <i>path</i>, will still refer to the STREAMS file after
the
<i>fdetach()</i>
has taken effect.
<p>
If there are no open file descriptors or other references to the STREAMS file,
then a successful call to
<i>fdetach()</i>
has the same effect as performing the last
<i><a href="close.html">close()</a></i>
on the attached file.
</blockquote><h4><a name = "tag_000_004_176">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>fdetach()</i>
returns 0.  Otherwise, it returns -1
and sets <i>errno</i> to indicate the error.
</blockquote><h4><a name = "tag_000_004_177">&nbsp;</a>ERRORS</h4><blockquote>
The
<i>fdetach()</i>
function will fail if:
<dl compact>

<dt>[EACCES]<dd>
Search permission is denied on a component of the path prefix.

<dt>[EPERM]<dd>
The effective user ID is not the owner of <i>path</i> and
the process does not have appropriate privileges.

<dt>[ENOTDIR]<dd>
A component of the path prefix is not a directory.

<dt>[ENOENT]<dd>
A component of <i>path</i> does not name an existing file
or <i>path</i> is an empty string.

<dt>[EINVAL]<dd>
The <i>path</i> argument names a file that is not currently attached.

<dt>[ENAMETOOLONG]<dd>

The size of a pathname exceeds {PATH_MAX}, or a pathname
component is longer than {NAME_MAX}.

<dt>[ELOOP]<dd>
Too many symbolic links were encountered in resolving <i>path</i>.

</dl>
<p>
The
<i>fdetach()</i>
function may fail if:
<dl compact>

<dt>[ENAMETOOLONG]<dd>

Pathname resolution of a symbolic link produced an intermediate result whose
length exceeds {PATH_MAX}.

</dl>
</blockquote><h4><a name = "tag_000_004_178">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_004_179">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_004_180">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_004_181">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="fattach.html">fattach()</a></i>,
<i><a href="stropts.h.html">&lt;stropts.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
